﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="easybbs_newtopic.aspx.cs" Inherits="easybbs_newtopic" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>发起新主题</title>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
    <style type="text/css">
        body{
            font-size:10pt;
        }
    </style>
    <script language=javascript src="./js/Function.js"></script>
    <script language=javascript src="./js/myCheck.js"></script>
	<script type="text/javascript" src="./jquery/126/jquery-1.2.6.js"></script>	<script type="text/javascript" src="./jquery/jquery.watermarkinput.js"></script>	<script type="text/javascript" src="./jquery/jquery.textLimiter.js"></script>	<script language="javascript" type="text/javascript">        //获取编辑器中HTML内容
        function getEditorHTMLContents(EditorName) { 
            var oEditor = FCKeditorAPI.GetInstance(EditorName); 
            return(oEditor.GetXHTML(true)); 
        }

        // 获取编辑器中文字内容
        function getEditorTextContents(EditorName) { 
            var oEditor = FCKeditorAPI.GetInstance(EditorName); 
            return(oEditor.EditorDocument.body.innerText); 
        }

        // 设置编辑器中内容
        function SetEditorContents(EditorName, ContentStr) { 
            var oEditor = FCKeditorAPI.GetInstance(EditorName); 
            oEditor.SetHTML(ContentStr) ; 
        }

        function topic_chk()
        {
			if(CheckText(form1.topictitle,"标题",50)==false) return false;
			if(getEditorHTMLContents('fck_content')=='')
			{
				alert("内容不能空!");
				return false;
			}
			return true;
        }
        function topic_save()
        {
	        $.ajax({	            url:'./ajax/topic_save.aspx',	            type:'post',	            data: "userid="+$("#myuid").val()+"&topictitle="+escape($("#topictitle").val())+"&topiccontent="+escape(getEditorHTMLContents("fck_content")),	            beforeSend:function()	            {	                return topic_chk();	            },	            error:function()	            {	                alert("发布失败！");	            },	            success: function()	            {	                alert("发布成功！");	                window.close();                    window.opener.gettopiclist(1)	            }	        });        };
	    	    function topic_clear()	    {	        $("#topictitle").val('');	        SetEditorContents('fck_content','');	        $("#topictitle").focus();	    }	    	    function topic_cancel()	    {	        if(confirm('确认是要取消发布吗？'))	        {	            window.close();	        }	    }	    $(document).ready(function(){	       $("#topictitle").Watermark("请输入标题,最多25个字符!");           $("#topictitle").textLimiter();	    });	</script></head>
<body>
    <form id="form1" runat="server">
    <div>
        <table border="1" cellpadding="2" cellspacing="0" style='BORDER-COLLAPSE: collapse' bordercolor="#cfdfff" width="96%" align="center">
            <tr bgcolor="#f5fafe">
                <td align="center" width="80">标&nbsp;&nbsp;题</td><td align="left"><input type="text" id="topictitle" maxlength="25" style="width: 400px" /></td>
            </tr>
            <tr>
                <td colspan=2><FCKeditorV2:FCKeditor ID="fck_content" runat="server" BasePath="/easycrm/fckeditor/" Height="400px" Width="100%" ToolbarSet="CMS01"></FCKeditorV2:FCKeditor></td>
            </tr>
            <tr bgcolor="#f5fafe">
                <td colspan=2><input id="btncancel" type="button" value="取消" onclick="topic_cancel()" style="width: 60px;" />&nbsp;<input id="btnreset" type="button" value="重写" onclick="topic_clear()" style="width: 60px;" />&nbsp;<input id="btnsave" type="button" value="提交" onclick="topic_save()" style="width: 60px;" /></td>
            </tr>
        </table>
    </div>
    <div id="myhidediv" style="VISIBILITY: hidden;"><asp:TextBox ID="myuid" runat="server"></asp:TextBox></div>
    </form>
</body>
</html>
